<!-- HTML header for doxygen 1.8.6-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<title>OpenCV: samples/cpp/filestorage.cpp</title>
<link href="../../opencv.ico" rel="shortcut icon" type="image/x-icon" />
<link href="../../tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../jquery.js"></script>
<script type="text/javascript" src="../../dynsections.js"></script>
<script type="text/javascript" src="../../tutorial-utils.js"></script>
<link href="../../search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="../../search/searchdata.js"></script>
<script type="text/javascript" src="../../search/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
//<![CDATA[
MathJax.Hub.Config(
{
  TeX: {
      Macros: {
          matTT: [ "\\[ \\left|\\begin{array}{ccc} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{array}\\right| \\]", 9],
          fork: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ \\end{array} \\right.", 4],
          forkthree: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ \\end{array} \\right.", 6],
          forkfour: ["\\left\\{ \\begin{array}{l l} #1 & \\mbox{#2}\\\\ #3 & \\mbox{#4}\\\\ #5 & \\mbox{#6}\\\\ #7 & \\mbox{#8}\\\\ \\end{array} \\right.", 8],
          vecthree: ["\\begin{bmatrix} #1\\\\ #2\\\\ #3 \\end{bmatrix}", 3],
          vecthreethree: ["\\begin{bmatrix} #1 & #2 & #3\\\\ #4 & #5 & #6\\\\ #7 & #8 & #9 \\end{bmatrix}", 9],
          cameramatrix: ["#1 = \\begin{bmatrix} f_x & 0 & c_x\\\\ 0 & f_y & c_y\\\\ 0 & 0 & 1 \\end{bmatrix}", 1],
          distcoeffs: ["(k_1, k_2, p_1, p_2[, k_3[, k_4, k_5, k_6 [, s_1, s_2, s_3, s_4[, \\tau_x, \\tau_y]]]]) \\text{ of 4, 5, 8, 12 or 14 elements}"],
          distcoeffsfisheye: ["(k_1, k_2, k_3, k_4)"],
          hdotsfor: ["\\dots", 1],
          mathbbm: ["\\mathbb{#1}", 1],
          bordermatrix: ["\\matrix{#1}", 1]
      }
  }
}
);
//]]>
</script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0/MathJax.js"></script>
<link href="../../doxygen.css" rel="stylesheet" type="text/css" />
<link href="../../stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<!--#include virtual="/google-search.html"-->
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="../../opencv-logo-small.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">OpenCV
   &#160;<span id="projectnumber">4.5.2</span>
   </div>
   <div id="projectbrief">Open Source Computer Vision</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "../../search",false,'Search');
</script>
<script type="text/javascript" src="../../menudata.js"></script>
<script type="text/javascript" src="../../menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('../../',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">samples/cpp/filestorage.cpp</div>  </div>
</div><!--header-->
<div class="contents">
<p>A complete example using the FileStorage interface</p>
<div class="fragment"><div class="line"><span class="comment">/*</span></div><div class="line"><span class="comment"> * filestorage_sample demonstrate the usage of the opencv serialization functionality</span></div><div class="line"><span class="comment"> */</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &quot;<a class="code" href="../../d0/d9c/core_2include_2opencv2_2core_8hpp.html">opencv2/core.hpp</a>&quot;</span></div><div class="line"><span class="preprocessor">#include &lt;iostream&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"></div><div class="line"><span class="keyword">using</span> std::string;</div><div class="line"><span class="keyword">using</span> std::cout;</div><div class="line"><span class="keyword">using</span> std::endl;</div><div class="line"><span class="keyword">using</span> std::cerr;</div><div class="line"><span class="keyword">using</span> std::ostream;</div><div class="line"><span class="keyword">using namespace </span><a class="code" href="../../d2/d75/namespacecv.html">cv</a>;</div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> help(<span class="keywordtype">char</span>** av)</div><div class="line">{</div><div class="line">  cout &lt;&lt; <span class="stringliteral">&quot;\nfilestorage_sample demonstrate the usage of the opencv serialization functionality.\n&quot;</span></div><div class="line">      &lt;&lt; <span class="stringliteral">&quot;usage:\n&quot;</span></div><div class="line">      &lt;&lt;  av[0] &lt;&lt; <span class="stringliteral">&quot; outputfile.yml.gz\n&quot;</span></div><div class="line">      &lt;&lt; <span class="stringliteral">&quot;\n   outputfile above can have many different extensions, see below.&quot;</span></div><div class="line">      &lt;&lt; <span class="stringliteral">&quot;\nThis program demonstrates the use of FileStorage for serialization, that is in use &lt;&lt; and &gt;&gt;  in OpenCV\n&quot;</span></div><div class="line">      &lt;&lt; <span class="stringliteral">&quot;For example, how to create a class and have it serialize, but also how to use it to read and write matrices.\n&quot;</span></div><div class="line">      &lt;&lt; <span class="stringliteral">&quot;FileStorage allows you to serialize to various formats specified by the file end type.&quot;</span></div><div class="line">          &lt;&lt; <span class="stringliteral">&quot;\nYou should try using different file extensions.(e.g. yaml yml xml xml.gz yaml.gz etc...)\n&quot;</span> &lt;&lt; endl;</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keyword">struct </span>MyData</div><div class="line">{</div><div class="line">  MyData() :</div><div class="line">    A(0), X(0), id()</div><div class="line">  {</div><div class="line">  }</div><div class="line">  <span class="keyword">explicit</span> MyData(<span class="keywordtype">int</span>) :</div><div class="line">    A(97), X(<a name="a0"></a><a class="code" href="../../db/de0/group__core__utils.html#ga677b89fae9308b340ddaebf0dba8455f">CV_PI</a>), id(<span class="stringliteral">&quot;mydata1234&quot;</span>)</div><div class="line">  {</div><div class="line">  }</div><div class="line">  <span class="keywordtype">int</span> A;</div><div class="line">  <span class="keywordtype">double</span> X;</div><div class="line">  <span class="keywordtype">string</span> id;</div><div class="line">  <span class="keywordtype">void</span> <a name="a1"></a><a class="code" href="../../d2/d75/namespacecv.html#a027b764f14e54f8838b5120e991bd29c">write</a>(<a name="_a2"></a><a class="code" href="../../da/d56/classcv_1_1FileStorage.html">FileStorage</a>&amp; fs) <span class="keyword">const</span> <span class="comment">//Write serialization for this class</span></div><div class="line">  {</div><div class="line">    fs &lt;&lt; <span class="stringliteral">&quot;{&quot;</span> &lt;&lt; <span class="stringliteral">&quot;A&quot;</span> &lt;&lt; A &lt;&lt; <span class="stringliteral">&quot;X&quot;</span> &lt;&lt; X &lt;&lt; <span class="stringliteral">&quot;id&quot;</span> &lt;&lt; <span class="keywordtype">id</span> &lt;&lt; <span class="stringliteral">&quot;}&quot;</span>;</div><div class="line">  }</div><div class="line">  <span class="keywordtype">void</span> <a name="a3"></a><a class="code" href="../../d2/d75/namespacecv.html#a9afba2f5b9bf298c62da8cf66184e41f">read</a>(<span class="keyword">const</span> <a name="_a4"></a><a class="code" href="../../de/dd9/classcv_1_1FileNode.html">FileNode</a>&amp; node)  <span class="comment">//Read serialization for this class</span></div><div class="line">  {</div><div class="line"></div><div class="line">    A = (int)node[<span class="stringliteral">&quot;A&quot;</span>];</div><div class="line">    X = (double)node[<span class="stringliteral">&quot;X&quot;</span>];</div><div class="line">    <span class="keywordtype">id</span> = (string)node[<span class="stringliteral">&quot;id&quot;</span>];</div><div class="line">  }</div><div class="line">};</div><div class="line"></div><div class="line"><span class="comment">//These write and read functions must exist as per the inline functions in operations.hpp</span></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="../../d2/d75/namespacecv.html#a027b764f14e54f8838b5120e991bd29c">write</a>(<a class="code" href="../../da/d56/classcv_1_1FileStorage.html">FileStorage</a>&amp; fs, <span class="keyword">const</span> std::string&amp;, <span class="keyword">const</span> MyData&amp; x){</div><div class="line">  x.write(fs);</div><div class="line">}</div><div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="../../d2/d75/namespacecv.html#a9afba2f5b9bf298c62da8cf66184e41f">read</a>(<span class="keyword">const</span> <a class="code" href="../../de/dd9/classcv_1_1FileNode.html">FileNode</a>&amp; node, MyData&amp; x, <span class="keyword">const</span> MyData&amp; default_value = MyData()){</div><div class="line">  <span class="keywordflow">if</span>(node.<a name="a5"></a><a class="code" href="../../de/dd9/classcv_1_1FileNode.html#a82d59aab4765da6140c238c54aadfa92">empty</a>())</div><div class="line">    x = default_value;</div><div class="line">  <span class="keywordflow">else</span></div><div class="line">    x.read(node);</div><div class="line">}</div><div class="line"></div><div class="line"><span class="keyword">static</span> ostream&amp; <a name="a6"></a><a class="code" href="../../d0/de1/group__core.html#gafdef54942b265b663de6bbc789d306e4">operator&lt;&lt;</a>(ostream&amp; out, <span class="keyword">const</span> MyData&amp; m){</div><div class="line">  out &lt;&lt; <span class="stringliteral">&quot;{ id = &quot;</span> &lt;&lt; m.id &lt;&lt; <span class="stringliteral">&quot;, &quot;</span>;</div><div class="line">  out &lt;&lt; <span class="stringliteral">&quot;X = &quot;</span> &lt;&lt; m.X &lt;&lt; <span class="stringliteral">&quot;, &quot;</span>;</div><div class="line">  out &lt;&lt; <span class="stringliteral">&quot;A = &quot;</span> &lt;&lt; m.A &lt;&lt; <span class="stringliteral">&quot;}&quot;</span>;</div><div class="line">  <span class="keywordflow">return</span> out;</div><div class="line">}</div><div class="line"><span class="keywordtype">int</span> main(<span class="keywordtype">int</span> ac, <span class="keywordtype">char</span>** av)</div><div class="line">{</div><div class="line">  <a name="_a7"></a><a class="code" href="../../d0/d2e/classcv_1_1CommandLineParser.html">cv::CommandLineParser</a> parser(ac, av,</div><div class="line">    <span class="stringliteral">&quot;{@input||}{help h ||}&quot;</span></div><div class="line">  );</div><div class="line">  <span class="keywordflow">if</span> (parser.<a name="a8"></a><a class="code" href="../../d0/d2e/classcv_1_1CommandLineParser.html#a8c41cf242b2ad8c0472e3b57893ef200">has</a>(<span class="stringliteral">&quot;help&quot;</span>))</div><div class="line">  {</div><div class="line">    help(av);</div><div class="line">    <span class="keywordflow">return</span> 0;</div><div class="line">  }</div><div class="line">  <span class="keywordtype">string</span> filename = parser.<a name="a9"></a><a class="code" href="../../d0/d2e/classcv_1_1CommandLineParser.html#a190215863579a6d244dccfd261ee0224">get</a>&lt;<span class="keywordtype">string</span>&gt;(<span class="stringliteral">&quot;@input&quot;</span>);</div><div class="line">  <span class="keywordflow">if</span> (filename.empty())</div><div class="line">  {</div><div class="line">    help(av);</div><div class="line">    <span class="keywordflow">return</span> 1;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">//write</span></div><div class="line">  {</div><div class="line">    <a class="code" href="../../da/d56/classcv_1_1FileStorage.html">FileStorage</a> fs(filename, <a name="a10"></a><a class="code" href="../../da/d56/classcv_1_1FileStorage.html#a973e41cb75ef6230412a567723b7482da747a241cefee7b8af34c3d804c864ad6">FileStorage::WRITE</a>);</div><div class="line"></div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;writing images\n&quot;</span>;</div><div class="line">    fs &lt;&lt; <span class="stringliteral">&quot;images&quot;</span> &lt;&lt; <span class="stringliteral">&quot;[&quot;</span>;</div><div class="line"></div><div class="line">    fs &lt;&lt; <span class="stringliteral">&quot;image1.jpg&quot;</span> &lt;&lt; <span class="stringliteral">&quot;myfi.png&quot;</span> &lt;&lt; <span class="stringliteral">&quot;baboon.jpg&quot;</span>;</div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;image1.jpg&quot;</span> &lt;&lt; <span class="stringliteral">&quot; myfi.png&quot;</span> &lt;&lt; <span class="stringliteral">&quot; baboon.jpg&quot;</span> &lt;&lt; endl;</div><div class="line"></div><div class="line">    fs &lt;&lt; <span class="stringliteral">&quot;]&quot;</span>;</div><div class="line"></div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;writing mats\n&quot;</span>;</div><div class="line">    <a name="_a11"></a><a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> R =<a name="a12"></a><a class="code" href="../../df/dfc/classcv_1_1Mat__.html#a992daefd1a256fbd40423a2cf77f42a1">Mat_&lt;double&gt;::eye</a>(3, 3),T = <a name="a13"></a><a class="code" href="../../df/dfc/classcv_1_1Mat__.html#ab68de1358f5aedd6028269f77a9e841b">Mat_&lt;double&gt;::zeros</a>(3, 1);</div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;R = &quot;</span> &lt;&lt; R &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;T = &quot;</span> &lt;&lt; T &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">    fs &lt;&lt; <span class="stringliteral">&quot;R&quot;</span> &lt;&lt; R;</div><div class="line">    fs &lt;&lt; <span class="stringliteral">&quot;T&quot;</span> &lt;&lt; T;</div><div class="line"></div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;writing MyData struct\n&quot;</span>;</div><div class="line">    MyData m(1);</div><div class="line">    fs &lt;&lt; <span class="stringliteral">&quot;mdata&quot;</span> &lt;&lt; m;</div><div class="line">    cout &lt;&lt; m &lt;&lt; endl;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">//read</span></div><div class="line">  {</div><div class="line">    <a class="code" href="../../da/d56/classcv_1_1FileStorage.html">FileStorage</a> fs(filename, <a name="a14"></a><a class="code" href="../../da/d56/classcv_1_1FileStorage.html#a973e41cb75ef6230412a567723b7482daa0dcc459c4d100c35ccfa9a643827bed">FileStorage::READ</a>);</div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (!fs.<a name="a15"></a><a class="code" href="../../da/d56/classcv_1_1FileStorage.html#aa952c31f4e632595cd5ac107913f4fd1">isOpened</a>())</div><div class="line">    {</div><div class="line">      cerr &lt;&lt; <span class="stringliteral">&quot;failed to open &quot;</span> &lt;&lt; filename &lt;&lt; endl;</div><div class="line">      help(av);</div><div class="line">      <span class="keywordflow">return</span> 1;</div><div class="line">    }</div><div class="line"></div><div class="line">    <a class="code" href="../../de/dd9/classcv_1_1FileNode.html">FileNode</a> n = fs[<span class="stringliteral">&quot;images&quot;</span>];</div><div class="line">    <span class="keywordflow">if</span> (n.<a name="a16"></a><a class="code" href="../../de/dd9/classcv_1_1FileNode.html#ad0fd448e25719a94320ebe574b87f997">type</a>() != <a name="a17"></a><a class="code" href="../../de/dd9/classcv_1_1FileNode.html#a296580c68b764fddeb2cd42912bd34ccaa359c2282183738d11a665035a1a67bb">FileNode::SEQ</a>)</div><div class="line">    {</div><div class="line">      cerr &lt;&lt; <span class="stringliteral">&quot;images is not a sequence! FAIL&quot;</span> &lt;&lt; endl;</div><div class="line">      <span class="keywordflow">return</span> 1;</div><div class="line">    }</div><div class="line"></div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;reading images\n&quot;</span>;</div><div class="line">    <a name="_a18"></a><a class="code" href="../../d7/d4e/classcv_1_1FileNodeIterator.html">FileNodeIterator</a> it = n.<a name="a19"></a><a class="code" href="../../de/dd9/classcv_1_1FileNode.html#a0f299820227506079f5b9013dd8c3558">begin</a>(), it_end = n.<a name="a20"></a><a class="code" href="../../de/dd9/classcv_1_1FileNode.html#a58b033e34726eb73f0238a1bfbe0c8e9">end</a>();</div><div class="line">    <span class="keywordflow">for</span> (; it != it_end; ++it)</div><div class="line">    {</div><div class="line">      cout &lt;&lt; (string)*it &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">    }</div><div class="line"></div><div class="line">    <a class="code" href="../../d3/d63/classcv_1_1Mat.html">Mat</a> R, T;</div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;reading R and T&quot;</span> &lt;&lt; endl;</div><div class="line"></div><div class="line">    fs[<span class="stringliteral">&quot;R&quot;</span>] &gt;&gt; R;</div><div class="line">    fs[<span class="stringliteral">&quot;T&quot;</span>] &gt;&gt; T;</div><div class="line"></div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;R = &quot;</span> &lt;&lt; R &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;T = &quot;</span> &lt;&lt; T &lt;&lt; endl;</div><div class="line"></div><div class="line">    MyData m;</div><div class="line">    fs[<span class="stringliteral">&quot;mdata&quot;</span>] &gt;&gt; m;</div><div class="line"></div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;read mdata\n&quot;</span>;</div><div class="line">    cout &lt;&lt; m &lt;&lt; endl;</div><div class="line"></div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;attempting to read mdata_b\n&quot;</span>;   <span class="comment">//Show default behavior for empty matrix</span></div><div class="line">    fs[<span class="stringliteral">&quot;mdata_b&quot;</span>] &gt;&gt; m;</div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;read mdata_b\n&quot;</span>;</div><div class="line">    cout &lt;&lt; m &lt;&lt; endl;</div><div class="line"></div><div class="line">  }</div><div class="line"></div><div class="line">  cout &lt;&lt; <span class="stringliteral">&quot;Try opening &quot;</span> &lt;&lt; filename &lt;&lt; <span class="stringliteral">&quot; to see the serialized data.&quot;</span> &lt;&lt; endl &lt;&lt; endl;</div><div class="line"></div><div class="line">  <span class="comment">//read from string</span></div><div class="line">  {</div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;Read data from string\n&quot;</span>;</div><div class="line">    <span class="keywordtype">string</span> dataString =</div><div class="line">        <span class="stringliteral">&quot;%YAML:1.0\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;mdata:\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;   A: 97\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;   X: 3.1415926535897931e+00\n&quot;</span></div><div class="line">        <span class="stringliteral">&quot;   id: mydata1234\n&quot;</span>;</div><div class="line">    MyData m;</div><div class="line">    <a class="code" href="../../da/d56/classcv_1_1FileStorage.html">FileStorage</a> fs(dataString, <a class="code" href="../../da/d56/classcv_1_1FileStorage.html#a973e41cb75ef6230412a567723b7482daa0dcc459c4d100c35ccfa9a643827bed">FileStorage::READ</a> | <a name="a21"></a><a class="code" href="../../da/d56/classcv_1_1FileStorage.html#a973e41cb75ef6230412a567723b7482dabdde7670c9c7e472f8445932ea7cbbf7">FileStorage::MEMORY</a>);</div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;attempting to read mdata_b from string\n&quot;</span>;   <span class="comment">//Show default behavior for empty matrix</span></div><div class="line">    fs[<span class="stringliteral">&quot;mdata&quot;</span>] &gt;&gt; m;</div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;read mdata\n&quot;</span>;</div><div class="line">    cout &lt;&lt; m &lt;&lt; endl;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="comment">//write to string</span></div><div class="line">  {</div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;Write data to string\n&quot;</span>;</div><div class="line">    <a class="code" href="../../da/d56/classcv_1_1FileStorage.html">FileStorage</a> fs(filename, <a class="code" href="../../da/d56/classcv_1_1FileStorage.html#a973e41cb75ef6230412a567723b7482da747a241cefee7b8af34c3d804c864ad6">FileStorage::WRITE</a> | <a class="code" href="../../da/d56/classcv_1_1FileStorage.html#a973e41cb75ef6230412a567723b7482dabdde7670c9c7e472f8445932ea7cbbf7">FileStorage::MEMORY</a> | <a name="a22"></a><a class="code" href="../../da/d56/classcv_1_1FileStorage.html#a973e41cb75ef6230412a567723b7482da63e7a7dcb2d68359210dc5fc8c83e92d">FileStorage::FORMAT_YAML</a>);</div><div class="line"></div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;writing MyData struct\n&quot;</span>;</div><div class="line">    MyData m(1);</div><div class="line">    fs &lt;&lt; <span class="stringliteral">&quot;mdata&quot;</span> &lt;&lt; m;</div><div class="line">    cout &lt;&lt; m &lt;&lt; endl;</div><div class="line">    <span class="keywordtype">string</span> createdString = fs.<a name="a23"></a><a class="code" href="../../da/d56/classcv_1_1FileStorage.html#a5341a9e09e1b797faf6b7ec40bd558fd">releaseAndGetString</a>();</div><div class="line">    cout &lt;&lt; <span class="stringliteral">&quot;Created string:\n&quot;</span> &lt;&lt; createdString &lt;&lt; <span class="stringliteral">&quot;\n&quot;</span>;</div><div class="line">  }</div><div class="line"></div><div class="line">  <span class="keywordflow">return</span> 0;</div><div class="line">}</div></div><!-- fragment --> </div><!-- contents -->
<!-- HTML footer for doxygen 1.8.6-->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Fri Apr 2 2021 11:36:29 for OpenCV by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="../../doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
<script type="text/javascript">
//<![CDATA[
addTutorialsButtons();
//]]>
</script>
</body>
</html>
